package com.ef.service.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.ef.dao.AttachmentDao;
import com.ef.domain.Attachment;
import com.ef.domain.FAQ;
import com.ef.service.AttachmentService;

public class AttachmentSericeImpl extends BaseServiceImpl implements
		AttachmentService {

	private AttachmentDao attachmentDao;

	public void delete(Attachment entity) {
		attachmentDao.delete(entity);
	}

	public List<Attachment> findByFAQ(FAQ faq) {
		DetachedCriteria detachedCriteria = DetachedCriteria
				.forClass(Attachment.class);
		detachedCriteria.add(Restrictions.eq("faq", faq));
		return attachmentDao.findAllByCriteria(detachedCriteria);
	}

	public Attachment findById(Long id) {
		return attachmentDao.findById(id);
	}

	public Attachment save(Attachment entity) {
		attachmentDao.save(entity);
		return entity;
	}

	public void saveOrUpdate(Attachment entity) {
		attachmentDao.saveOrUpdate(entity);
	}

	public AttachmentDao getAttachmentDao() {
		return attachmentDao;
	}

	public void setAttachmentDao(AttachmentDao attachmentDao) {
		this.attachmentDao = attachmentDao;
	}

}
